cmake_minimum_required(VERSION 3.00)

project(csp)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)

set(SYSTEM_CPU_COMPILER "${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}_${CMAKE_C_COMPILER_ID}")
string(TOLOWER "${SYSTEM_CPU_COMPILER}" SYSTEM_CPU_COMPILER)
message("SYSTEM_CPU_COMPILER: ${SYSTEM_CPU_COMPILER}")

file(GLOB_RECURSE CSP_SRCS "include/*.h" "src/*.h" "src/*.c")

if (CSP_TEST)
    file(GLOB_RECURSE TESTS_SRCS "tests/*.h" "tests/*.c" "tests/*.cpp")
    set(CSP_SRCS ${CSP_SRCS} ${TESTS_SRCS})
endif ()

if (CSP_TEST)
    add_executable(${PROJECT_NAME} ${CSP_SRCS})
    target_link_libraries(${PROJECT_NAME} pthread rt)
else ()
    add_library(${PROJECT_NAME}_${SYSTEM_CPU_COMPILER} ${CSP_SRCS})
endif ()
